package com.rightrule.rule.executor.node;

import com.rightrule.rule.compile.Executable;
import com.rightrule.rule.executor.RuntimeContext;
import com.rightrule.rule.executor.rule.BaseRule;
import com.rightrule.rule.response.NodeExecutionResponse;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

@Data
@Slf4j
public class ExecuteNode extends BaseNode implements Executable {

    /**
     *  规则内容
     */
    private BaseRule ruleInfo;

    /**
     *  执行节点，执行方法
     * @param context
     * @param variableMap
     * @return
     */
    @Override
    public NodeExecutionResponse execute(RuntimeContext context, Map<String, Object> variableMap) {
        return ruleInfo.execute(context,variableMap);
    }

    @Override
    public String toString() {
        return "ExecuteNode{" +
                "ruleInfo=" + ruleInfo +
                '}';
    }
}
